using UnityEngine;

[ExecuteInEditMode]
public class AimPull : MonoBehaviour
{
	public bool enablePull;

	public bool useScale;

	public Transform up;

	public Transform left;

	public Transform right;

	public Transform down;

	public Transform leftUp;

	public Transform rightUp;

	public Transform leftDown;

	public Transform rightDown;

	public float curShift;

	private float lerpShift;

	private void Awake()
	{
		base.enabled = enablePull;
	}

	private void Update()
	{
		lerpShift = Mathf.Lerp(lerpShift, curShift, Time.deltaTime * 15f);
		SetAimShift(lerpShift);
	}

	private void SetAimShift(float shift)
	{
		if (!enablePull)
		{
			return;
		}
		if ((bool)up)
		{
			if (useScale)
			{
				up.localScale = Vector3.one * shift;
			}
			else
			{
				up.localPosition = Vector3.up * shift;
			}
		}
		if ((bool)down)
		{
			if (useScale)
			{
				up.localScale = Vector3.one * shift;
			}
			else
			{
				down.localPosition = Vector3.down * shift;
			}
		}
		if ((bool)right)
		{
			if (useScale)
			{
				right.localScale = Vector3.one * shift;
			}
			else
			{
				right.localPosition = Vector3.right * shift;
			}
		}
		if ((bool)left)
		{
			if (useScale)
			{
				left.localScale = Vector3.one * shift;
			}
			else
			{
				left.localPosition = Vector3.left * shift;
			}
		}
		float num = shift * 0.7f;
		if ((bool)leftUp)
		{
			leftUp.localPosition = new Vector3(0f - num, num, 0f);
		}
		if ((bool)rightUp)
		{
			rightUp.localPosition = new Vector3(num, num, 0f);
		}
		if ((bool)leftDown)
		{
			leftDown.localPosition = new Vector3(0f - num, 0f - num, 0f);
		}
		if ((bool)rightDown)
		{
			rightDown.localPosition = new Vector3(num, 0f - num, 0f);
		}
	}

	public void Shot(float spread)
	{
		if (useScale)
		{
			curShift = 0.5f * spread;
		}
		else
		{
			curShift = 10f * spread;
		}
	}

	private void OnDisable()
	{
	}
}
